/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Clases;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Bryan
 */
@Entity
@Table(name = "curso")
@NamedQueries({
    @NamedQuery(name = "Curso.findAll", query = "SELECT c FROM Curso c"),
    @NamedQuery(name = "Curso.findByIdCurso", query = "SELECT c FROM Curso c WHERE c.idCurso = :idCurso"),
    @NamedQuery(name = "Curso.findByNombre", query = "SELECT c FROM Curso c WHERE c.nombre = :nombre"),
    @NamedQuery(name = "Curso.findByVigente", query = "SELECT c FROM Curso c WHERE c.vigente = :vigente")})
public class Curso implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idCurso")
    private Short idCurso;
    @Basic(optional = false)
    @Column(name = "Nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "Vigente")
    private boolean vigente;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "curso")
    private Collection<Catedraticocurso> catedraticocursoCollection;

    public Curso() {
    }

    public Curso(Short idCurso) {
        this.idCurso = idCurso;
    }

    public Curso(Short idCurso, String nombre, boolean vigente) {
        this.idCurso = idCurso;
        this.nombre = nombre;
        this.vigente = vigente;
    }

    public Short getIdCurso() {
        return idCurso;
    }

    public void setIdCurso(Short idCurso) {
        Short oldIdCurso = this.idCurso;
        this.idCurso = idCurso;
        changeSupport.firePropertyChange("idCurso", oldIdCurso, idCurso);
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        String oldNombre = this.nombre;
        this.nombre = nombre;
        changeSupport.firePropertyChange("nombre", oldNombre, nombre);
    }

    public boolean getVigente() {
        return vigente;
    }

    public void setVigente(boolean vigente) {
        boolean oldVigente = this.vigente;
        this.vigente = vigente;
        changeSupport.firePropertyChange("vigente", oldVigente, vigente);
    }

    public Collection<Catedraticocurso> getCatedraticocursoCollection() {
        return catedraticocursoCollection;
    }

    public void setCatedraticocursoCollection(Collection<Catedraticocurso> catedraticocursoCollection) {
        this.catedraticocursoCollection = catedraticocursoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCurso != null ? idCurso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Curso)) {
            return false;
        }
        Curso other = (Curso) object;
        if ((this.idCurso == null && other.idCurso != null) || (this.idCurso != null && !this.idCurso.equals(other.idCurso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "escuela.Curso[idCurso=" + idCurso + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
